For the treatment of apneas and other respiratory disorders, breathable gas is supplied from a mechanical respirator or ventilator, for example via a mask, at a pressure which may be higher during inspiration and lower during expiration. (In this specification any reference to a “mask” is to be understood as including all forms of devices for passing breathable gas to a person's airway, including nose masks, nose and mouth masks, nasal prongs/pillows and endrotracheal or tracheostomy tubes. The term “ventilator” is used to describe any device that does part of the work of breathing.) Typically one measures the subject's respiratory airflow during mechanical ventilation to assess adequacy of treatment, or to control the operation of the ventilator.
Respiratory airflow is commonly measured with a pneumotachograph placed in the gas delivery path between the mask and the pressure source. Leaks between the mask and the subject are unavoidable. The pneumotachograph measures the sum of the respiratory airflow plus the flow through the leak plus flow through the vent (also called “deliberate leak”). If the instantaneous flow through the leak is known, the respiratory airflow can be calculated by subtracting the flow through the leak and the flow through the vent from the flow at the pneumotach. Typically the flow through the vent is a known function of pressure at the vent, and given that the pressure at the vent can be estimated with reasonable accuracy, the flow through the vent can then be straightforwardly calculated. On the other hand, if the vent characteristics are suitable for the leak model employed, the vent flow and non-deliberate leak can be lumped together and estimated as a single quantity. The direct estimation of vent flow using pressure at the vent will be assumed hereinafter, and subtraction of this vent flow from total ventilator outflow will be assumed to have occurred when not mentioned explicitly.
Some methods to correct for the flow through the leak assume (i) that the leak is substantially constant, and (ii) that over a sufficiently long time, inspiratory and expiratory respiratory airflow will cancel. If these assumptions are met, the average flow through the pneumotach over a sufficiently long period will equal the magnitude of the leak, and the true respiratory airflow may then be calculated as described.
The known method is only correct if the pressure at the mask is constant. If, on the other hand, the mask pressure varies with time (for example, in the case of a ventilator), assumption (i) above will be invalid, and the calculated respiratory airflow will therefore be incorrect. This is shown markedly in FIGS. 1a-1f. 
FIG. 1a shows a trace of measured mask pressure in bi-level CPAP (Continuous Positive Airway Pressure) treatment between about 4 cm H2O on expiration and 12 cm H2O on inspiration. FIG. 1b shows a trace of true respiratory airflow in synchronism with the mask pressures. At time=21 seconds a mask leak occurs, resulting in a leakage flow from the leak that is a function of the treatment pressure, as shown in FIG. 1c. The measured mask flow shown in FIG. 1d now includes an offset due to the leak flow. The prior art method then determines the calculated leak flow over a number of breaths, as shown in FIG. 1e. The resulting calculated respiratory flow, as the measured flow minus the calculating leak flow is shown in FIG. 1f, having returned to the correct mean value, however is incorrectly scaled in magnitude, giving a false indication of peak positive and negative airflow.
Another prior art arrangement is disclosed in European Publication No. 0 714 670 A2, including a calculation of a pressure-dependent leak component. The methodology relies on knowing precisely the occurrence of the start of an inspiratory event and the start of the next inspiratory event. In other words, the leak calculation is formed as an average over a known breath and applied to a subsequent breath.
This method cannot be used if the moment of start and end of the previous breath are unknown. In general, it can be difficult to accurately calculate the time of start of a breath. This is particularly the case immediately following a sudden change in the leak.
Furthermore, the method will not work in the case of a subject who is making no respiratory efforts, and is momentarily not being ventilated at all, for example during an apnea, because for the duration of the apnea there is no start or end of breath over which to make a calculation.
In U.S. Pat. No. 6,152,129 (Berthon-Jones) the leak is determined by first estimating the conductance of the leak path from the long term orifice flow:
            1              R        L              =                  <        Q        >                    <                  p                >              ,where GL=1/RL is conductance (L denotes leak), Q is instantaneous flow, p is instantaneous pressure and < >denotes a long term average calculated for example by low pass filtering with an IIF or other filter having a long time constant. Note that the word “average” as used herein contains the general sense inclusive of the result of a low pass filtering step, and is not limited to an arithmetic mean or other standard average such as the RMS average.The instantaneous leak flow, based on the model of the flow through an orifice is then
      Q    L    =            1              R        L              ⁢          √      p      
Note that the instantaneous respiratory airflow is thenQR=Q−QL.
Berthon-Jones attempts to deal with sudden changes in instantaneous leak flow by dynamically adjusting the filter's time constant using fuzzy logic, lengthening the time constant if it is certain that the leak is steady, reducing the time constant if it is certain that the leak has suddenly changed, and using intermediately longer or shorter time constants if it is intermediately certain that the leak is steady.
Berthon-Jones also develops a jamming index by fuzzy logic to deal with the case of a large and sudden increase in the conductance of the leak, in which case the calculated respiratory airflow will be incorrect. In particular during apparent inspiration, the calculated respiratory airflow will be large positive for a time that is large compared with the expected duration of a normal inspiration. Conversely, if there is a sudden decrease in conductance of the leak, then during apparent expiration the calculated respiratory airflow will be large negative for a time that is large compared with the duration of normal expiration.
Therefore, the jamming index, i.e. an index of the degree of certainty that the leak has suddenly changed, is derived, such that the longer the airflow has been away from zero, and by a larger amount, the larger the index. The explicit calculation of the jamming index by fuzzy logic is described in the '129 patent, which is incorporated herein by reference.
The time constant for the low pass filters is then adjusted to vary inversely with the jamming index. In operation, if there is a sudden and large change in the leak, the index will be large, and the time constant for the calculation of the conductance of the leak will be small, allowing rapid convergence on the new value of the leakage conductance. Conversely, if the leak is steady for a long time, the index will be small, and the time constant for calculation of the leakage conductance will be large; enabling accurate calculation of the instantaneous respiratory airflow. In the spectrum of intermediate situations, where the calculated instantaneous respiratory airflow is larger and for longer periods, the index will be progressively larger, and the time constant for the calculation of the leak will progressively reduce. For example, at a moment in time where it is uncertain whether the leak is in fact constant, and the subject merely commenced a large sigh, or whether in fact there has been a sudden increase in the leak, the index will be of an intermediate value, and the time constant for calculation of the impedance of the leak will also be of an intermediate value.